// 用户相关类型
export interface User {
  id: string;
  username: string;
  email: string;
  password: string; // 加密存储
  avatar: string; // 头像URL
  nickname: string;
  gender: 'male' | 'female' | 'other';
  bio: string; // 个人简介
  preferences: object; // 偏好设置
  createdAt: Date;
  updatedAt: Date;
  lastLogin: Date;
  totalGames: number; // 总游戏次数
  wins: number; // 胜利次数
  points: number; // 积分
  isVerified?: boolean; // 是否已认证
  isAdmin?: boolean; // 是否是管理员
  achievements?: Achievement[]; // 用户成就
}

export interface LoginRequest {
  username: string;
  password: string;
}

export interface RegisterRequest {
  username: string;
  email: string;
  password: string;
  nickname?: string;
}

export interface UpdateUserRequest {
  nickname?: string;
  email?: string;
  gender?: 'male' | 'female' | 'other';
  bio?: string;
  avatar?: string;
}

export interface ChangePasswordRequest {
  currentPassword: string;
  newPassword: string;
  confirmPassword: string;
}

// 海龟汤题目相关类型
export interface Soup {
  id: string;
  title: string;
  surface: string; // 汤面
 汤底: string; // 汤底
  difficulty: 'easy' | 'medium' | 'hard';
  theme: string[];
  creatorId: string | null; // 创建者ID，系统题目为null
  isOfficial: boolean; // 是否官方题目
  status: 'draft' | 'pending' | 'published' | 'rejected';
  playCount: number; // 游玩次数
  rating: number; // 评分
  createdAt: Date;
  updatedAt: Date;
  publishedAt: Date;
}

export interface CreateSoupRequest {
  title: string;
  surface: string;
 汤底: string;
  difficulty: 'easy' | 'medium' | 'hard';
  theme: string[];
  isOfficial?: boolean;
}

// 游戏记录相关类型
export interface GameRecord {
  id: string;
  userId: string;
  soupId: string;
  soup?: {
    id: string;
    title: string;
    difficulty: 'easy' | 'medium' | 'hard';
  };
  status: 'ongoing' | 'completed' | 'abandoned';
  startTime: Date;
  endTime: Date | null;
  questions: string[]; // 用户提问历史
  answers: string[]; // AI回答历史
  score: number | null; // 得分
  hintsUsed: number; // 使用提示次数
}

// 聊天相关类型
export interface ChatMessage {
  id: string;
  roomId?: string | null; // 聊天室ID，私聊为null
  senderId: string;
  receiverId?: string | null; // 私聊接收者ID
  content: string;
  type: 'text' | 'image' | 'system';
  createdAt: Date;
}

export interface ChatRoom {
  id: string;
  name: string;
  lastMessage?: ChatMessage | null;
  unreadCount: number;
  users: number;
}

export interface PrivateChat {
  userId: string;
  username: string;
  nickname?: string;
  avatar?: string;
  isOnline: boolean;
  lastMessage?: ChatMessage | null;
  unreadCount: number;
}

export interface SendMessageRequest {
  roomId?: string | null;
  receiverId?: string | null;
  content: string;
  type: 'text' | 'image' | 'system';
}

// 游戏房间相关类型
export interface GameRoom {
  id: string;
  name: string;
  owner: {
    id: string;
    username: string;
    nickname?: string;
    avatar?: string;
  };
  players: Array<{
    id: string;
    username: string;
    nickname?: string;
    avatar?: string;
  }>;
  maxPlayers: number;
  status: 'waiting' | 'playing' | 'closed';
  password?: string;
  currentSoup: { id: string; title: string; difficulty: 'easy' | 'medium' | 'hard' } | null;
  createdAt: Date;
}

export interface CreateRoomRequest {
  name: string;
  maxPlayers: number;
  password?: string;
  soupId?: string;
  public?: boolean;
  allowHints?: boolean;
  timeLimit?: boolean;
}

// 成就相关类型
export interface Achievement {
  id: string;
  name: string;
  description: string;
  icon: string;
  unlocked: boolean;
  unlockDate?: Date;
  progress: number;
}

// 排行榜相关类型
export interface LeaderboardEntry {
  id: string;
  userId: string;
  username: string;
  nickname?: string;
  avatar?: string;
  points: number;
  rank: number;
  change: number; // 排名变化
}

// 通用响应类型
export interface ApiResponse<T = any> {
  success: boolean;
  data?: T;
  error?: string;
  message?: string;
}

// 分页相关类型
export interface Pagination {
  page: number;
  pageSize: number;
  totalItems: number;
  totalPages: number;
}

export interface PaginatedResponse<T> {
  items: T[];
  pagination: Pagination;
}